<!--Copyright (C) Kherty.  All rights reserved.-->
<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:ss="http://schemas.Kherty.com/office/2007/spreadsheet" 
  xmlns:oui="http://schemas.Kherty.com/office/2007" 
  xmlns:ssui="clr-namespace:OpenLS.Spreadsheet.UI" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:Internals="clr-namespace:OpenLS.Spreadsheet.UI.Internals"
  x:Class="OpenLS.Spreadsheet.UI.TableResources">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ssui:FilterColumnResources/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </ResourceDictionary.MergedDictionaries>
  <DataTemplate DataType="{x:Type ss:Table}" x:Key="tableButtons">
    <ItemsControl Name="itemsControl" ItemsSource="{Binding AutoFilter.FilterColumns, Converter={x:Static Internals:SpreadsheetConverters.FilterColumnViewModelsFactory}}">
      <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
          <ssui:WorksheetGrid x:Name="forTables" 
            Background="{x:Null}"
                              Top="{Binding RelativeSource={RelativeSource Self}, Path=(ssui:SpreadsheetElement.WorksheetPane).Top, Mode=OneWay}"
                              Left="{Binding RelativeSource={RelativeSource Self}, Path=(ssui:SpreadsheetElement.WorksheetPane).Left, Mode=OneWay}"
            Columns="{Binding Path=Range.Worksheet.Columns}"
            Rows="{Binding Path=Range.Worksheet.Rows}"/>
        </ItemsPanelTemplate>
      </ItemsControl.ItemsPanel>
      <ItemsControl.ItemContainerStyle>
        <Style>
          <Setter Property="ssui:WorksheetGrid.Row" Value="{Binding Range.Row}"/>
          <Setter Property="ssui:WorksheetGrid.Column" Value="{Binding Column.Index}"/>
          <Setter Property="Control.HorizontalAlignment" Value="Right"/>
          <Setter Property="Control.VerticalAlignment" Value="Stretch"/>
        </Style>
      </ItemsControl.ItemContainerStyle>

    </ItemsControl>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding HeaderRowCount}" Value="0">
                <Setter TargetName="itemsControl" Property="ItemsSource" Value="{x:Null}"/>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type Table}" x:Key="tableBackground">
        <Internals:TableBackgroundControl Left="{Binding Range.Column}" Top="{Binding Range.Row}" Table="{Binding}"
                                     ShowColumnStripes="{Binding ShowColumnStripes}"
                                     ShowFirstColumn="{Binding ShowFirstColumn}"
                                     ShowLastColumn="{Binding ShowLastColumn}"
                                     ShowRowStripes="{Binding ShowRowStripes}"/>
    </DataTemplate>
    <DataTemplate DataType="{x:Type Table}" x:Key="tableBorders">
        <Internals:TableBordersControl Left="{Binding Range.Column}" Top="{Binding Range.Row}" Table="{Binding}"
                                     ShowColumnStripes="{Binding ShowColumnStripes}"
                                     ShowFirstColumn="{Binding ShowFirstColumn}"
                                     ShowLastColumn="{Binding ShowLastColumn}"
                                     ShowRowStripes="{Binding ShowRowStripes}"/>
    </DataTemplate>
    <Style x:Key="tableBackgroundContainerStyle">
        <Setter Property="ssui:WorksheetGrid.Column" Value="{Binding Range.Column}"/>
        <Setter Property="ssui:WorksheetGrid.Row" Value="{Binding Range.Row}"/>
        <Setter Property="ssui:WorksheetGrid.ColumnSpan" Value="{Binding Range.ColumnSpan}"/>
        <Setter Property="ssui:WorksheetGrid.RowSpan" Value="{Binding Range.RowSpan}"/>
        <Setter Property="ssui:WorksheetGrid.IsFullRow" Value="{Binding Range.IsFullRow}"/>
        <Setter Property="ssui:WorksheetGrid.IsFullColumn" Value="{Binding Range.IsFullColumn}"/>
    </Style>

</ResourceDictionary>